package com.lxd.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * @Author Dongdong
 * @注释
 */
@FeignClient(value = "beacon-cache")
public interface cacheClient {
    @PostMapping(value = "/cache/setnNx/{key}/{value}/{ttl}")
    public boolean setNx(@PathVariable(value = "key") String key,
                      @RequestParam(value = "value") Object value,
                      @PathVariable(value = "ttl") Long ttl );
    @GetMapping("/cache/hget/{key}/{field}")
    public Object hget(@PathVariable(value = "key")String key, @PathVariable(value = "field")String field);
    @GetMapping("/cache/hget/{key}/{field}")
    public String hgetString(@PathVariable(value = "key")String key, @PathVariable(value = "field")String field);
    @GetMapping("/cache/smembers/{key}")
    public Set smembers(@PathVariable(value = "key") String key);
    @GetMapping("/cache/smembers/{key}")
    public Set<Map> smemberMap(@PathVariable(value = "key")String key);

    @GetMapping("/cache/get/{key}")
    public Object get(@PathVariable(value = "key") String key);
    @GetMapping("/cache/get/{key}")
    public String getString(@PathVariable(value = "key") String key);

    @PostMapping(value = "/cache/set/{key}")
    public void set(@PathVariable(value = "key") String key, @RequestParam(value = "value") Object value) ;
    @PostMapping(value = "/cache/zadd/{key}/{score}/{member}")
    public Boolean zadd(@PathVariable(value = "key")String key,
                        @PathVariable(value = "score")Long score,
                        @PathVariable(value = "member")Object member);
    @GetMapping(value = "/cache/zrangebyscorecount/{key}/{start}/{end}")
    public int zRangeByScoreCount(@PathVariable(value = "key") String key,
                                  @PathVariable(value = "start") Double start,
                                  @PathVariable(value = "end") Double end);


    @DeleteMapping(value = "/cache/zremove/{key}/{member}")
    public void zRemove(@PathVariable(value = "key") String key,@PathVariable(value = "member") String member);


    @PostMapping(value = "/cache/hincrby/{key}/{field}/{delta}")
    public Long hIncrBy(@PathVariable(value = "key") String key,
                        @PathVariable(value = "field") String field,
                        @PathVariable(value = "delta") Long delta);

    @PostMapping(value = "/cache/incr/{key}/{delta}")
    public Long Incr(@PathVariable(value = "key") String key,
                     @PathVariable(value = "delta") Long delta);

    @PostMapping(value = "/cache/decr/{key}/{delta}")
    public Long decr(@PathVariable(value = "key") String key,
                     @PathVariable(value = "delta") Long delta);

    @PostMapping(value = "/cache/hmset/{key}")
    public void hSet(@PathVariable(value = "key") String key, @RequestBody Map<String, Object> value) ;

    @GetMapping("/cache/hgetall/{key}")
    public Map hGetAll(@PathVariable(value = "key")String key);

}
